import type { loginType, loginTypeByPassword,registerType } from "@/types/login"
import { sendRequest } from "@/utils/http"

export const getVerificationCode = (phone:string) =>{ //获取验证码
  let data = {phone:phone}
  return sendRequest<string>({
    url:"/server-user/login/code",
    method:"GET",//delete请求也是这样
    data:data
  })
}
export const loginAPI = (loginType:loginType) =>{ //验证码登录
  let data = loginType
  return sendRequest<string>({
    url:"/server-user/login/loginByCode",
    method:"POST",//put请求也是这样
    data:data
  })
}

export const loginAPIByPassword = (loginType:loginTypeByPassword) => { //密码登录
  let data = loginType
  return sendRequest<string>({
    url: "/server-user/login/loginByPassword",
    method: "POST",//put请求也是这样
    data: data
  })
}

export const registerAPI = (registerType: registerType) => {  //注册
  let data = registerType
  return sendRequest<string>({
    url: "/server-user/login/registerByCode",
    method: "POST",//put请求也是这样
    data: data
  })
}

//登录页展示
//GET /login/show
export const getloginShowAPI = () =>{
  return sendRequest<string>({
    url:"/login/show",
    method:"GET",//put请求也是这样
  }) 
}
